package com.customer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.customer.dao.IntegrationHistoryMapper;
import com.customer.service.OperLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nameless.entity.IntegrationHistory;
import com.nameless.vo.IntegrationHistoryVo;
import com.nameless.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author WHZ
 * @date 2023年02月28日 12:03
 */
@Service
public class OperLogServiceImpl extends ServiceImpl<IntegrationHistoryMapper, IntegrationHistory> implements OperLogService {

    @Autowired
    private IntegrationHistoryMapper operLogMapper;

    @Override
    public Result<List<IntegrationHistory>> findAll(IntegrationHistoryVo integrationHistoryVo) {
        PageHelper.startPage(integrationHistoryVo.getPageNo(),integrationHistoryVo.getPageSize());
        QueryWrapper<IntegrationHistory> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(integrationHistoryVo.getOrderNo()!=null,"orderNo",integrationHistoryVo.getOrderNo());
        List<IntegrationHistory> operLogs = operLogMapper.selectList(queryWrapper);
        PageInfo<IntegrationHistory> tPageInfo = new PageInfo<>(operLogs);
        return new Result(200,"查询成功",tPageInfo);
    }

    @Override
    public Result del(Integer operId) {
        int i = operLogMapper.deleteById(operId);
        return new Result(200,"删除成功",i);
    }
}
